/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.velocityme.utility;

import java.io.Serializable;
import java.util.Date;

/**
 *
 * @author rcrida
 */
public abstract class Licence implements Serializable {

    private Date m_creationDate;
    private Date m_expiryDate;
    private String m_clientGUID;

    /** Creates a new instance of LicenseKey */
    public Licence(Date p_expiryDate, String p_clientGUID) {
        m_creationDate = new Date();
        m_expiryDate = p_expiryDate;
        m_clientGUID = p_clientGUID;
    }

    public Licence() {
    }

    public Date getCreationDate() { return m_creationDate; }
    public void setCreationDate(Date p_creationDate) { m_creationDate = p_creationDate; }

    public Date getExpiryDate() { return m_expiryDate; }
    public void setExpiryDate(Date p_expiryDate) { m_expiryDate = p_expiryDate; }

    public String getClientGUID() { return m_clientGUID; }
    public void setClientGUID(String p_clientGUID) { m_clientGUID = p_clientGUID; }

    public boolean isMatchingGUID(String p_clientGUID) {
        return p_clientGUID.equals(m_clientGUID);
    }

    public boolean isValid() {
        return m_expiryDate.after(new Date());
    }

    public abstract boolean addNewSession(int p_numCurrentSessions, String p_username);

}
